//
//  YJWGuideView.m
//  百思不得骑姐
//
//  Created by YJW on 16/11/3.
//  Copyright © 2016年 yijiang. All rights reserved.
//

#import "YJWGuideView.h"

@implementation YJWGuideView

+(void)showGuideView
{
    NSString *key = @"CFBundleShortVersionString";
    
    //获取当前版本号
    NSString *currentVersion = [NSBundle mainBundle].infoDictionary[key];
    //获取之前上一个版本号
    NSString *sanBoxVersion = [[NSUserDefaults standardUserDefaults] valueForKey:key];
    
    //判断两个版本号，如果不相同，就进行导航视图显示
    if (![currentVersion isEqualToString:sanBoxVersion]) {
        UIWindow *window = [UIApplication sharedApplication].keyWindow;
        UIView *guideView = [[NSBundle mainBundle] loadNibNamed:NSStringFromClass([self class]) owner:nil options:nil].lastObject;
        
        guideView.frame = window.bounds;
        [window addSubview:guideView];
        
        //更新沙盒中版本号
        [[NSUserDefaults standardUserDefaults] setValue:currentVersion forKey:key];
        [[NSUserDefaults standardUserDefaults] synchronize];
    }
}

- (IBAction)moveAway {
    //移除控件
    [self removeFromSuperview];
}

@end
